package com.zlq.ajaxjson.controller;


import com.zlq.ajaxjson.dao.UserDaoLo;
import com.zlq.ajaxjson.entity.User;
import net.sf.json.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/aloginController")
public class AloginController extends HttpServlet {
    private UserDaoLo ud = new UserDaoLo();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("name");
        System.out.println("过来了");
        System.out.println(name);
        User u = new User("zhang", 123);
        PrintWriter out = resp.getWriter();
        out.write(JSONObject.fromObject(u).toString());
        out.flush();
        out.close();
    }
}
